package top.i51213.fastaction.view;

import android.content.Context;

import com.tencent.smtt.sdk.ReaderWizard;
import com.tencent.smtt.sdk.TbsReaderView;

import java.lang.reflect.Field;

public class ReaderView extends TbsReaderView{
    public ReaderView(Context context, TbsReaderView.ReaderCallback readerCallback) throws RuntimeException {
        super(context, readerCallback);
    }

    public ReaderWizard getReaderWizard() {
        try {
            Field field = getClass().getSuperclass().getDeclaredField("b");
            field.setAccessible(true);
            return (ReaderWizard) field.get(this);
        } catch (Exception e) {
            //e.printStackTrace();
            return null;
        }
    }
    public Object getTbsReader(){
        ReaderWizard readerWizard=getReaderWizard();
        return readerWizard!=null?readerWizard.getTbsReader():null;
    }
    public Object getInnerReader() {
        try {
            Object object= getTbsReader();
            if(object==null)return null;
            Field field = object.getClass().getDeclaredField("mReader");
            field.setAccessible(true);
            return field.get(object);
        } catch (Exception e) {
            return null;
        }
    }
}
